Attribute VB_Name = "CoreAPI32"
'Core-API32.BAS: Core Application Programming Interface
'    32-bit Basic Module file for Visual Basic 5.0.
'Supports ALL America Online versions with seemless inte-
'    gration.
'BAS file by Anubis with help from Vishnu and various progr-
'   ammers.
'www.coredesign.net, www.reapers.org, www.reapers.org/elysium
'#reapers on EFNet
'webmaster@reapers.org

'Beta version 0.9 release 980927 [3]

Type PROCESSENTRY32
    dwSize As Long
    cntUsage As Long
    th32ProcessID As Long
    th32DefaultHeapID As Long
    th32ModuleID As Long
    cntThreads As Long
    th32ParentProcessID As Long
    pcPriClassBase As Long
    dwFlags As Long
    szExeFile(260) As Byte
    End Type
    
Private Type OsVersionInfo
    dwVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatform As Long
    szCSDVersion As String * 128
    End Type
    
Private OsVer As OsVersionInfo
    
Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, ByRef lppe As PROCESSENTRY32) As Long
Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, ByRef lppe As PROCESSENTRY32) As Long

Const TH32CS_SNAPPROCESS = &H2

'Unworking
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Boolean
Public Declare Function setactivewindow Lib "user32" Alias "SetActiveWindow" (ByVal hWnd As Long) As Boolean
Public Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Boolean
Attribute BringWindowToTop.VB_Description = "Brings a window to the top of all other windows and gives it focus."

Public Const TCM_FIRST = &H1300 '0x1300, 4864
Public Const TCM_SETCURSEL = TCM_FIRST + 11

'Global Consts added by Anubis

'Win_PositionForm
Public Const winCENTER = 0
Public Const winLEFTTOP = 1
Public Const winLEFTMIDDLE = 2
Public Const winLEFTBOTTOM = 3
Public Const winRIGHTTOP = 4
Public Const winRIGHTMIDDLE = 5
Public Const winRIGHTBOTTOM = 6
Public Const winCENTERTOP = 7
Public Const winCENTERBOTTOM = 8

'Win_Align
Public Const winUNDERRIGHT = 0
Public Const winUNDERLEFT = 1
Public Const winLEFT = 2
Public Const winRIGHT = 3

'API Global Consts - added before finalization of BAS file
Const VER_PLATFORM_WIN32_WINDOWS = 1
Const VER_PLATFORM_WIN32_NT = 2

'API Subs, Functions, Types and Consts

Type Rect
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type

Type POINTAPI
   x As Long
   y As Long
End Type

Type ConvertPointAPI
    xy As Long
End Type

Declare Function SndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Declare Function RegisterClipboardFormat Lib "user32" Alias "RegisterClipboardFormatA" (ByVal lpString As String) As Long
Declare Function setwindowtext Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Long) As Long
Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Long, ByVal lpBuffer As String, ByVal nSize As Long, ByRef lpNumberOfBytesWritten As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Sub RtlMoveMemory Lib "kernel32" (ByRef dest As Any, ByRef source As Any, ByVal nBytes As Long)
Declare Function RedrawWindow Lib "user32" (ByVal hWnd As Long, lprcUpdate As Rect, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As Rect) As Long
Declare Function SetRect Lib "user32" (lpRect As Rect, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Declare Function dwGetStringFromLPSTR Lib "dwspy32.dll" (ByVal lpcopy As Long) As String
Declare Sub dwCopyDataBynum Lib "dwspy32.dll" Alias "dwCopyData" (ByVal source&, ByVal dest&, ByVal nCount&)
Declare Function dwGetAddressForObject& Lib "dwspy32.dll" (object As Any)
Declare Sub dwCopyDataByString Lib "dwspy32.dll" Alias "dwCopyData" (ByVal source As String, ByVal dest As Long, ByVal nCount&)
Declare Function dwXCopyDataBynumFrom& Lib "dwspy32.dll" Alias "dwXCopyDataFrom" (ByVal mybuf As Long, ByVal foreignbuf As Long, ByVal size As Integer, ByVal foreignPID As Long)
Declare Function dwGetWndInstance& Lib "dwspy32.dll" (ByVal hWnd&)
Declare Function RegisterWindowMessage& Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String)
Declare Function GetWindowLong& Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long)
Declare Function EnumWindows& Lib "user32" (ByVal lpenumfunc As Long, ByVal lparam As Long)
Declare Function SendMessageByNum& Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lparam As Long)
Declare Function GetClassName& Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Attribute DrawMenuBar.VB_Description = "Draws the menu bar."
Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Attribute FindWindow.VB_Description = "Returns the handle of a window based on the classname and caption you pass to it."
Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lparam As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lparam As Long) As Long
Attribute SendMessage.VB_Description = "Sends a Windows Message, with the parameters you specify, to a target window."
Declare Function CreatePopupMenu Lib "user32" () As Long
Attribute CreatePopupMenu.VB_Description = "Creates a popupmenu."
Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function GetMenuItemID Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Declare Function getmenu Lib "user32" Alias "GetMenu" (ByVal hWnd As Long) As Long
Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Declare Function GetTopWindow Lib "user32" (ByVal hWnd As Long) As Long
Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cX As Long, ByVal cY As Long, ByVal wFlags As Long) As Long
Declare Function SetFocusAPI Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long
Declare Function GetMenuString Lib "user32" Alias "GetMenuStringA" (ByVal hMenu As Long, ByVal wIDItem As Long, ByVal lpString As String, ByVal nMaxCount As Long, ByVal wFlag As Long) As Long
Declare Function getwindowtext Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Declare Function InsertMenu Lib "user32" Alias "InsertMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As String) As Long
Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As String) As Long
Attribute AppendMenu.VB_Description = "Adds a menu to a application."
Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Attribute RemoveMenu.VB_Description = "Removes a window."
Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Attribute DeleteMenu.VB_Description = "Deletes a menu."
Declare Function DestroyMenu Lib "user32" (ByVal hMenu%) As Integer
Attribute DestroyMenu.VB_Description = "Destroys a menu."
Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Attribute CreateEllipticRgn.VB_Description = "Creates a circular region in memory that you can use to constrain a window or more commonally, a window."
Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal SectionName As String, ByVal KeyName As Any, ByVal ValueToSave As Any, ByVal filename As String) As Long
Attribute WritePrivateProfileString.VB_Description = "Write to an INI file."
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal SectionName As String, ByVal KeyName As Any, ByVal DefaultValue As String, ByVal StringToPlaceResultsIn As String, ByVal LenOfStringForResults As Long, ByVal filename As String) As Long
Attribute GetPrivateProfileString.VB_Description = "Get information from an INI file."
Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFilename As String, ByVal nSize As Long) As Long
Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lparam As Long) As Long
Declare Function GetBinaryType Lib "kernel32" Alias "GetBinaryTypeA" (ByVal lpApplicationName As String, lpBinaryType As Long) As Long
Declare Function GetWindowWord Lib "user32" (ByVal hWnd As Long, ByVal nIndex As Long) As Integer
Declare Function GetForegroundWindow Lib "user32" () As Long
Declare Function GetFocus Lib "user32" () As Long
Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpStruct As OsVersionInfo) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function CreatePolygonRgn Lib "gdi32" (ByRef lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Attribute CreatePolygonRgn.VB_Description = "Creates a polygon shaped region in memory that you can use to contraint a window, or commonly a shape."
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Attribute DeleteObject.VB_Description = "Deletes an object.  Very good for freeing up memory and ALWAYS use this after EVERY API graphical effect you do with the GDI API library."
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, ByVal wMapType As Long) As Long
Declare Function ExitWindows Lib "user32" (ByVal dwReserved As Long, ByVal uReturnCode As Long) As Long
Attribute ExitWindows.VB_Description = "Exits windows, can reboot computer, log on as a different user... depends on the parameters you pass it."
        
Public Const MOUSE_MOVE = &HF012
Public Const WM_SYSCOMMAND = &H112
Public Const WM_CHAR = &H102
Public Const WM_SETTEXT = &HC
Public Const WM_USER = &H400
Public Const WM_KEYDOWN = &H100
Public Const WM_KEYUP = &H101
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_CLOSE = &H10
Public Const WM_COMMAND = &H111
Public Const WM_CLEAR = &H303
Public Const WM_DESTROY = &H2
Public Const WM_GETTEXT = &HD
Public Const WM_GETTEXTLENGTH = &HE
Public Const WM_LBUTTONDBLCLK = &H203
Public Const BM_GETCHECK = &HF0
Public Const BM_GETSTATE = &HF2
Public Const BM_SETCHECK = &HF1
Public Const BM_SETSTATE = &HF3

Public Const LB_GETITEMDATA = &H199
Public Const LB_GETCOUNT = &H18B
Public Const LB_ADDSTRING = &H180
Public Const LB_DELETESTRING = &H182
Public Const LB_FINDSTRING = &H18F
Public Const LB_FINDSTRINGEXACT = &H1A2
Public Const LB_GETCURSEL = &H188
Public Const LB_GETTEXT = &H189
Public Const LB_GETTEXTLEN = &H18A
Public Const LB_SELECTSTRING = &H18C
Public Const LB_SETCOUNT = &H1A7
Public Const LB_SETCURSEL = &H186
Public Const LB_SETSEL = &H185
Public Const LB_INSERTSTRING = &H181

Public Const VK_HOME = &H24
Public Const VK_RIGHT = &H27
Public Const VK_CONTROL = &H11
Public Const VK_DELETE = &H2E
Public Const VK_DOWN = &H28
Public Const VK_LEFT = &H25
Public Const VK_RETURN = &HD
Public Const VK_SPACE = &H20
Public Const VK_TAB = &H9
Public Const VK_SNAPSHOT = &H2C

Public Const HWND_TOP = 0
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE

Public Const GW_CHILD = 5
Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDLAST = 1
Public Const GW_HWNDNEXT = 2
Public Const GW_HWNDPREV = 3
Public Const GW_MAX = 5
Public Const GW_OWNER = 4
Public Const SW_MAXIMIZE = 3
Public Const SW_MINIMIZE = 6
Public Const SW_HIDE = 0
Public Const SW_RESTORE = 9
Public Const SW_SHOW = 5
Public Const SW_SHOWDEFAULT = 10
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOWNORMAL = 1

Public Const MF_APPEND = &H100&
Public Const MF_DELETE = &H200&
Public Const MF_CHANGE = &H80&
Public Const MF_ENABLED = &H0&
Public Const MF_DISABLED = &H2&
Public Const MF_REMOVE = &H1000&
Public Const MF_POPUP = &H10&
Public Const MF_STRING = &H0&
Public Const MF_UNCHECKED = &H0&
Public Const MF_CHECKED = &H8&
Public Const MF_GRAYED = &H1&
Public Const MF_BYPOSITION = &H400&
Public Const MF_BYCOMMAND = &H0&

Public Const GWW_HINSTANCE = (-6)
Public Const GWW_ID = (-12)
Public Const GWL_STYLE = (-16)

Public Const PROCESS_VM_READ = &H10
Public Const STANDARD_RIGHTS_REQUIRED = &HF0000

Public Function IM_Answer(ByVal ansMessage As String) As String
'By Anubis

AOL% = AOL_hWnd()
IM% = FindChildByTitle(AOL%, ">Instant Message From:")
If IM% = 0 Then IM% = FindChildByTitle(AOL%, "  Instant Message From:")
If IM% = 0 Then Exit Function
msgMessage$ = IM_GetIMText(IM%)
SN$ = IM_GetSNFromIM(IM%)
Win_Close IM%
IM_Send SN$, ansMessage$
IM_Answer$ = msgMessage$
End Function
Public Function IM_GetIMText(ByRef IM As Integer) As String
'By Anubis

If AOL_Version() = 25 Then
    imView$ = "_AOL_EDIT"
   Else
    imView$ = "RICHCNTL"
    End If
View% = FindChildByClass(IM%, imView$)
IM_GetIMText$ = API_GetText(View%)
End Function
Public Function IM_GetSNFromIM(ByRef IM As Integer) As String
'By Anubis

msgMessage$ = IM_GetIMText(IM%)
IM_GetSNFromIM$ = Left$(msgMessage$, InStr(msgMessage$, ":") - 1)
End Function
Public Function INI_ReadValue(ByVal Section As String, ByVal KeyName As String, ByVal INIFile As String) As Variant
buf$ = Space(255)
Q% = GetPrivateProfileString(Section$, KeyName$, vbNullString, buf$, 255, INIFile$)
INI_ReadValue = Left$(buf$, Q%)
End Function
Public Function INI_WriteValue(ByVal Section As String, ByVal KeyName As String, ByVal vValue As Variant, ByVal INIFile As String)
Q% = WritePrivateProfileString(Section$, KeyName$, CStr(vValue), INIFile$)
End Function
Public Function Mail_SearchBySubject(ByVal StringToFind As String, Optional mailType As Integer) As String
'By Anubis
'Returns the index of the first item that is found that matches
'StringToFind.  Searches by Subject.

If IsMissing(mailType%) Then mailType = 0
AOL% = AOL_hWnd()
Select Case mailType
    Case 1
        mailCount% = Mail_CountOldMail()
    Case 2
        mailCount% = Mail_CountSentMail()
    Case Else
        mailCount% = Mail_CountNewMail()
    End Select
If AOL_Version() = 4 Then
    mailhWnd% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
    Tree% = API_GetNextType(mailhWnd%, "_AOL_TREE", mailType% + 1)
   Else
    Tree% = FindChildByClass(AOL%, "_AOL_TREE")
    End If
ReDim virtualMailBox(0 To mailCount - 1) As String
For i = 0 To mailCount% - 1
    mailStr$ = Space(255)
    Q% = SendMessageByString(Tree%, LB_GETTEXT, i, mailStr$)
    NoDate$ = Mid$(mailStr$, InStr(mailStr$, "/") + 4)
    NoSN$ = Mid$(NoDate$, InStr(NoDate$, Chr(9)) + 1)
    virtualMailBox(i) = VB_ScriptSpaces(Left$(NoSN$, InStr(NoSN$, Chr(9)) - 1))
    DoEvents
    Next i
StringToFind$ = VB_ScriptSpaces(StringToFind$)
For i = 0 To mailCount% - 1
    If virtualMailBox(i) Like StringToFind$ Then
        Final$ = Final$ & CStr(i) & ","
        End If
    Next i
Mail_SearchBySubject$ = Left$(Final$, Len(Final$) - 1)
End Function
Public Sub Mail_MailToList(Lst As ListBox, Optional mailType As Integer)
If IsMissing(mailType%) Then mailType = 0
AOL% = AOL_hWnd()
Select Case mailType
    Case 1
        mailCount% = Mail_CountOldMail()
    Case 2
        mailCount% = Mail_CountSentMail()
    Case Else
        mailCount% = Mail_CountNewMail()
    End Select
If AOL_Version() = 4 Then
    mailhWnd% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
    Tree% = API_GetNextType(mailhWnd%, "_AOL_TREE", mailType% + 1)
   Else
    Tree% = FindChildByClass(AOL%, "_AOL_TREE")
    End If
For i = 0 To mailCount% - 1
    mailStr$ = Space(255)
    Q% = SendMessageByString(Tree%, LB_GETTEXT, i, mailStr$)
    NoDate$ = Mid$(mailStr$, InStr(mailStr$, "/") + 4)
    NoSN$ = Mid$(NoDate$, InStr(NoDate$, Chr(9)) + 1)
    Lst.AddItem Left$(NoSN$, Q%)
    DoEvents
    Next i
End Sub
Public Function Mail_MailToString(Optional mailType As Integer) As String
'By Anubis

If IsMissing(mailType%) Then mailType = 0
AOL% = AOL_hWnd()
Select Case mailType
    Case 1
        mailCount% = Mail_CountOldMail()
    Case 2
        mailCount% = Mail_CountSentMail()
    Case Else
        mailCount% = Mail_CountNewMail()
    End Select
If AOL_Version() = 4 Then
    mailhWnd% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
    Tree% = API_GetNextType(mailhWnd%, "_AOL_TREE", mailType% + 1)
   Else
    Tree% = FindChildByClass(AOL%, "_AOL_TREE")
    End If
For i = 0 To mailCount% - 1
    mailStr$ = Space(255)
    Q% = SendMessageByString(Tree%, LB_GETTEXT, i, mailStr$)
    NoDate$ = Mid$(mailStr$, InStr(mailStr$, "/") + 4)
    NoSN$ = Mid$(NoDate$, InStr(NoDate$, Chr(9)) + 1)
    Final$ = Final$ & Left$(NoSN$, Q%) & vbCrLf
    DoEvents
    Next i
Mail_MailToString$ = CStr(Final$)
End Function
Public Sub Mail_MailToClipBoard(Optional mailType As Integer)
'By Anubis
If IsMissing(mailType%) Then mailType% = 0
Clipboard.SetText Mail_MailToString()
End Sub
Public Function Mail_OpenMailBox(Optional mailType As Integer) As Integer
'By Anubis
'0 = new mail, 1 = old mail, 2 = sent mail
'If the AOL Version is 4.0, it will return the handle of the
'_AOL_TREE, otherwise it returns the handle of the mail window.

If IsMissing(mailType%) Then mailType% = 0
AOL% = AOL_hWnd()
Select Case mailType%
    Case 1
        If AOL_Version() = 4 Then
            AOL4_RunToolbar "MAIL"
            Do Until mailBox% <> 0
                DoEvents
                mailBox% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
                Timeout 0.001
                Loop
            TabCtrl% = FindChildByClass(mailBox%, "_AOL_TABCONTROL")
            Click TabCtrl%
            SetForegroundWindow TabCtrl%
            vKey = MapVirtualKey(VK_RIGHT, 0)
            keybd_event VK_RIGHT, vKey, 0, 0
            keybd_event VK_RIGHT, vKey, KEYEVENTF_KEYUP, 0
            mailBox% = API_GetNextType(mailBox%, "_AOL_TREE", 2)
           Else
            mailBox% = FindChildByTitle(AOL%, "Old Mail")
            If mailBox% = 0 Then
                RunMenuByString "Check Mail You've &Read"
                Do Until mailBox% <> 0 Or Mssg% <> 0
                    DoEvents
                    mailBox% = FindChildByTitle(AOL%, "Old Mail")
                    Mssg% = AOL_MsgBox()
                    Timeout 0.001
                    Loop
                End If
            End If
    Case 2
        If AOL_Version() = 4 Then
            AOL4_RunToolbar "MAIL"
            Do Until mailBox% <> 0
                DoEvents
                mailBox% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
                Timeout 0.001
                Loop
            TabCtrl% = FindChildByClass(mailBox%, "_AOL_TABCONTROL")
            Click TabCtrl%
            SetForegroundWindow TabCtrl%
            vKey = MapVirtualKey(VK_LEFT, 0)
            keybd_event VK_LEFT, vKey, 0, 0
            keybd_event VK_LEFT, vKey, KEYEVENTF_KEYUP, 0
            mailBox% = API_GetNextType(mailBox%, "_AOL_TREE", 3)
           Else
            mailBox% = FindChildByTitle(AOL%, "Outgoing Mail")
            If mailBox% = 0 Then
                RunMenuByString "Check Mail You've &Sent"
                Do Until mailBox% <> 0 Or Mssg% <> 0
                    DoEvents
                    mailBox% = FindChildByTitle(AOL%, "Outgoing Mail")
                    Mssg% = AOL_MsgBox()
                    Timeout 0.001
                    Loop
                End If
            End If
    Case Else
        If AOL_Version = 4 Then
            AOL4_RunToolbar ("MAIL")
            mail% = 0
            Do Until mail% <> 0
                DoEvents
                mail% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
                Timeout 0.001
                Loop
            mailBox% = FindChildByClass(mail%, "_AOL_TREE")
           Else
            AOL_RunToolbar ("MAIL")
            mail% = 0
            Do Until mail% <> 0
                DoEvents
                mail% = FindChildByTitle(AOL%, "New Mail")
                Timeout 0.001
                Loop
            End If
    End Select
Mail_OpenMailBox% = mailBox%
End Function

Public Function Mail_SearchBySender(ByVal senderName As String, Optional mailType As Integer) As String
'By Anubis
'Returns a comma delimitated list of mail indexes that the
'senderName was found as the sender.

If IsMissing(mailType%) Then mailType = 0
AOL% = AOL_hWnd()
Select Case mailType
    Case 1
        mailCount% = Mail_CountOldMail()
    Case 2
        mailCount% = Mail_CountSentMail()
    Case Else
        mailCount% = Mail_CountNewMail()
    End Select
If AOL_Version() = 4 Then
    mailhWnd% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
    Tree% = API_GetNextType(mailhWnd%, "_AOL_TREE", mailType% + 1)
   Else
    Tree% = FindChildByClass(AOL%, "_AOL_TREE")
    End If
ReDim virtualMailBox(0 To mailCount - 1) As String
For i = 0 To mailCount% - 1
    mailStr$ = Space(255)
    Q% = SendMessageByString(Tree%, LB_GETTEXT, i, mailStr$)
    NoDate$ = Mid$(mailStr$, InStr(mailStr$, "/") + 4)
    virtualMailBox(i) = VB_ScriptSpaces(Left$(NoDate$, InStr(NoDate$, Chr(9)) - 1))
    DoEvents
    Next i
senderName$ = VB_ScriptSpaces(senderName$)
For i = 0 To mailCount% - 1
    If virtualMailBox(i) Like senderName$ Then
        Final$ = Final$ & CStr(i) & ","
        End If
    Next i
Mail_SearchBySender$ = Left$(Final$, Len(Final$) - 1)
End Function

Public Sub PlaySound(ByRef wavName As String)
Attribute PlaySound.VB_Description = "Plays a WAV sound."
'By Anubis

If FileExist(wavName) = True Then Q% = SndPlaySound(wavName, 1)
End Sub

Function AOL_AOLDir() As String
Attribute AOL_AOLDir.VB_Description = "Returns the America Online directory (the location of waol.exe)."
'By Banickula, modifed by Anubis

Dim hThreadId As Long
Dim hProcessId As Long
Dim hSnapshot As Long
Dim lSuccess As Long
Dim lppe As PROCESSENTRY32

hThreadId = GetWindowThreadProcessId(AOL_hWnd(), hProcessId)
If CBool(hThreadId) = False Then Exit Function
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapshot = -1 Then Exit Function
lppe.dwSize = LenB(lppe)
lSuccess = Process32First(hSnapshot, lppe)
If Not CBool(lSuccess) Then
    Call CloseHandle(hSnapshot)
    Exit Function
    End If
While ((lppe.th32ProcessID <> hProcessId) And lSuccess)
    lSuccess = Process32Next(hSnapshot, lppe)
    Wend
If lppe.th32ProcessID = hProcessId Then
    AOL_AOLDir$ = Left$(LCase$(StrConv(lppe.szExeFile, vbUnicode)), InStr(LCase$(StrConv(lppe.szExeFile, vbUnicode)), "\waol.exe") - 1)
    End If
Call CloseHandle(hSnapshot)
End Function


Public Sub AOL4_SilentKeyword(ByVal URL As String)
Attribute AOL4_SilentKeyword.VB_Description = "Keyword on AOL 4.0, no interface calls used."
If AOL_Version() = 4 Then
    On Error Resume Next
    sil$ = CStr(AOL_AOLDir() & "\waol.exe -s" & URL$)
    Q% = Shell(sil$)
   Else
    AOL_Keyword URL$
    End If
End Sub
Function API_GetWindowsVersion() As String
Attribute API_GetWindowsVersion.VB_Description = "Returns the MS Windows version."
'Base by WiLL (Vishnu), created by Anubis

OsVer.dwVersionInfoSize = 148&
Q% = GetVersionEx(OsVer)
Select Case OsVer.dwPlatform
    Case VER_PLATFORM_WIN32_NT
        subVer = (OsVer.dwMajorVersion * 100) + OsVer.dwMinorVersion
        If subVer < 351 Then
            API_GetWindowsVersion = "WinNT 3.50"
           Else
            API_GetWindowsVersion = "WinNT 3.51+"
            End If
    Case VER_PLATFORM_WIN32_WINDOWS
        API_GetWindowsVersion = "Win 95+"
    Case Else
        API_GetWindowsVersion = "Win 3.1 Win32s"
    End Select
End Function
Public Function FileExist(ByVal filName As String) As Boolean
Attribute FileExist.VB_Description = "Checks to see if a specified file exists.  If it does, the function returns true, otherwise it returns false."
'By Anubis

On Error Resume Next
If Len(Dir$(filName$)) Then FileExist = True Else FileExist = False
End Function

Public Sub IM_Send(ByVal SN As String, ByVal Msg As String)
Attribute IM_Send.VB_Description = "Sends an instant message."
'By Anubis

AOL% = AOL_hWnd()
If AOL_Version() = 4 Then
    AOL4_SilentKeyword "aol://9293:" & SN$
   Else
    RunMenuByString "Send an Instant Message"
    End If
Do Until IM% <> 0
    DoEvents
    IM% = FindChildByTitle(AOL%, "Send Instant Message")
    Timeout 0.001
    Loop
EditBox% = FindChildByClass(IM%, "_AOL_EDIT")
Select Case AOL_Version()
    Case 25
    RichBox% = API_GetNextType(IM%, "_AOL_EDIT", 2)
    Case Else
    RichBox% = FindChildByClass(IM%, "RICHCNTL")
    End Select
SendBttn% = GetWindow(RichBox%, GW_HWNDNEXT)
DoEvents
API_SetText EditBox%, SN$
API_SetText RichBox%, Msg$
Click SendBttn%
For i = 0 To 8
    DoEvents
    If AOL_MsgBox() <> 0 Then
        Click FindChildByTitle(AOL_MsgBox, "OK")
        End If
    Timeout 0.01
    Next i
Win_Close IM%
End Sub


Public Sub IM_Off()
Attribute IM_Off.VB_Description = "Turns your instant messages off."
'By Anubis

IM_Send "$IM_OFF", "  "
End Sub



Public Sub IM_On()
Attribute IM_On.VB_Description = "Turns your instant messages on."
'By Anubis

IM_Send "$IM_ON", " "
End Sub



Public Sub Mail_SendMail(ByVal SN As String, ByVal Subj As String, ByVal Msg As String)
Attribute Mail_SendMail.VB_Description = "Sends a message using AOL's mail."
'By Anubis, help from Sty

AOL% = AOL_hWnd()
Ver% = AOL_Version()
AOL4_RunToolbar "WRITE"
Do Until CompMail% <> 0
    DoEvents
    If Ver% = 4 Then
        CompMail% = FindChildByTitle(AOL%, "Write Mail")
       Else
        CompMail% = FindChildByTitle(AOL%, "Compose Mail")
        End If
    Timeout 0.001
    Loop
Do Until ToEdit% <> 0 And SubjEdit% <> 0
    DoEvents
    ToEdit% = FindChildByClass(CompMail%, "_AOL_EDIT")
    SubjEdit% = API_GetNextType(CompMail%, "_AOL_EDIT", 3)
    Timeout 0.001
    Loop
Do Until MsgEdit% <> 0
    DoEvents
    If Ver% = 25 Then
        MsgEdit% = API_GetNextType(CompMail%, "_AOL_EDIT", 4)
       Else
        MsgEdit% = FindChildByClass(CompMail%, "RICHCNTL")
        End If
    Timeout 0.001
    Loop
Do Until SendBttn% <> 0
    DoEvents
    If AOL_Version() = 4 Then
        CheckBox% = FindChildByClass(CompMail%, "_AOL_CHECKBOX")
        SendBttn% = GetWindow(CheckBox%, GW_HWNDNEXT)
       Else
        SendBttn% = FindChildByClass(CompMail%, "_AOL_ICON")
        End If
    Timeout 0.001
    Loop
API_SetText ToEdit%, SN$
API_SetText SubjEdit%, Subj$
API_SetText MsgEdit%, CStr(Msg$)
Do Until CompMail% = 0
    DoEvents
    Click SendBttn%
    If Ver% = 4 Then
        CompMail% = FindChildByTitle(AOL%, "Write Mail")
       Else
        CompMail% = FindChildByTitle(AOL%, "Compose Mail")
        End If
    Timeout 0.001
    Loop
For i = 0 To 49
    DoEvents
    MailSent% = FindWindow("_AOL_MODAL", vbNullString)
    If MailSent% <> 0 Then Exit For
    Timeout 0.01
    Next i
If Ver% = 4 Then
    Click FindChildByClass(MailSent%, "_AOL_ICON")
   Else
    Click FindChildByTitle(MailSent%, "OK")
    End If
End Sub

Public Function Menu_MenuExist(ByVal MenuTitle As String) As Boolean
Attribute Menu_MenuExist.VB_Description = "Returns true if a menu you are searching for exists in the parent window."
'By Anubis, fixed by HackSmurf

ToSearch% = getmenu(FindWindow("AOL Frame25", vbNullString))
MenuCount% = GetMenuItemCount(ToSearch%)
For i = 0 To MenuCount% - 1
    Buffer$ = String(Len(MenuTitle), Chr(0))
    ToSearchSub% = GetSubMenu(ToSearch%, i)
    MenuItemCount% = GetMenuItemCount(ToSearchSub%)
    Q% = GetMenuString(ToSearch%, i, Buffer$, Len(Buffer$) + 1, MF_BYPOSITION)
    If Left$(LCase(Buffer$), Len(MenuTitle)) Like LCase(MenuTitle) Then
        Menu_MenuExist = True
        Exit Function
        End If
    For n = 0 To MenuItemCount% - 1
        SubCount% = GetMenuItemID(ToSearchSub%, n)
        Buffer$ = String$(Len(MenuTitle), Chr(0))
        Q% = GetMenuString(ToSearchSub%, SubCount%, Buffer$, Len(MenuTitle) + 1, 1)
        If Left$(LCase(Buffer$), Len(MenuTitle)) Like LCase(MenuTitle) Then
            Menu_MenuExist = True
            Exit Function
            End If
        Next n
    Next i
MatchString:
End Function



Public Function Room_GetLastChatLine() As String
Attribute Room_GetLastChatLine.VB_Description = "Returns the last chat line said in the room."
'From Master32, modified by Anubis

Room% = Room_FindRoom()
View = FindChildByClass(Room%, "_AOL_View")
GetTrim = SendMessageByNum(View, 14, 0&, 0&)
TrimSpace$ = Space$(GetTrim)
GetString = SendMessageByString(View, 13, GetTrim + 1, TrimSpace$)
theview$ = TrimSpace$
For FindChar = 1 To Len(theview$)
    thechar$ = Mid(theview$, FindChar, 1)
    thechars$ = thechars$ & thechar$
    If thechar$ = Chr(13) Then
        thechatext$ = Mid(thechars$, 1, Len(thechars$) - 1)
        thechars$ = ""
        End If
    Next FindChar
lastlen = Val(FindChar) - Len(thechars$)
lastline = Mid(theview$, lastlen + 1, Len(thechars$) - 1)
Room_GetLastChatLine = lastline
End Function


Public Function Room_IsInRoom() As Boolean
Attribute Room_IsInRoom.VB_Description = "Checks to see if the user is in a chat room."
'By Anubis

If Room_FindRoom() = False Then
    Room_IsInRoom = False
    Beep
    MsgBox "You must be in a chat room to use this feature.", vbOKOnly + vbCritical, App.Title
   Else
    Room_IsInRoom = True
    End If
End Function

Public Function AOL_IsOnline() As Boolean
Attribute AOL_IsOnline.VB_Description = "Returs true if the user is online, false otherwise."
'By Anubis

If FindChildByTitle(AOL_hWnd, "Welcome, " & AOL_GetSN()) = False Then
    Beep
    MsgBox "You must be signed online to use this feature.", vbOKOnly + vbCritical, App.Title
    AOL_IsOnline = False
   Else
    AOL_IsOnline = True
    End If
End Function
Public Sub AOL_KillHourglass()
Attribute AOL_KillHourglass.VB_Description = "Destroys the hourglass cursor when AOL is processing and returns the pointer cursor."
'By Anubis
RunMenuByString "Stop Incoming Text"
End Sub
Public Function AOL_MsgBox() As Integer
Attribute AOL_MsgBox.VB_Description = "Returns the value of the first found message box created by the America Online program."
'By Anubis

AOL_MsgBox% = FindWindow("#32770", "America Online")
End Function
Public Function API_GetMsgBoxText(ByRef MBox As Integer) As String
Attribute API_GetMsgBoxText.VB_Description = "Returns the message box text of the handle of a message box you pass it."
'By Anubis

If MBox% = 0 Then API_GetMsgBoxText = ""
mBoxText% = API_GetNextType(MBox, "STATIC", 2)
API_GetMsgBoxText = API_GetText(mBoxText%)
End Function
Public Sub AOL_RunToolbar(ByVal Querry As String)
Attribute AOL_RunToolbar.VB_Description = "Clicks the AOL Toolbar based on position or a string you pass as a parameter.  If you use AOL 4.0, it will call AOL4_RunToolbar by default."
'By Anubis

If AOL_Version() = 4 Then
    AOL4_RunToolbar (Querry$)
    Exit Sub
    End If
Tool% = AOL_Tool()
Select Case UCase(CStr(Querry$))
    Case "MAIL", "READ", "NEW MAIL", "NEWMAIL", "1"
    Click FindChildByClass(Tool%, "_AOL_ICON")
    Case "WRITE", "COMPOSE", "2"
    Click API_GetNextIcon(Tool%, 2)
    Case "CHANNELS", "CHANNEL", "3"
    Click API_GetNextIcon(Tool%, 3)
    Case "HOT", "NEW", "4"
    Click API_GetNextIcon(Tool%, 4)
    Case "CHAT", "ROOM", "PEOPLE", "5"
    Click API_GetNextIcon(Tool%, 5)
    Case "FILESEARCH", "SEARCH", "6"
    Click API_GetNextIcon(Tool%, 6)
    Case "QUOTES", "STOCKS", "7"
    Click API_GetNextIcon(Tool%, 7)
    Case "NEWS", "8"
    Click API_GetNextIcon(Tool%, 8)
    Case "INTERNET", "NET", "WWW", "9"
    Click API_GetNextIcon(Tool%, 9)
    Case "CART", "MARKET", "MARKETPLACE", "10"
    Click API_GetNextIcon(Tool%, 10)
    Case "MY AOL", "MY", "11"
    Click API_GetNextIcon(Tool%, 11)
    Case "CLOCK", "ONLINE CLOCK", "12"
    Click API_GetNextIcon(Tool%, 12)
    Case "PRINT", "13"
    Click API_GetNextIcon(Tool%, 13)
    Case "PFC", "PERSONAL FILING CABINENT", "14"
    Click API_GetNextIcon(Tool%, 14)
    Case "FAVORITES", "FAV", "15"
    Click API_GetNextIcon(Tool%, 15)
    Case "MEM", "MEMBER", "QUESTION", "?"
    Click API_GetNextIcon(Tool%, 16)
    Case "FIND", "17"
    Click API_GetNextIcon(Tool%, 17)
    Case "KEYWORD", "18"
    Click API_GetNextIcon(Tool%, 18)
    Case "CENTER", "MAIL CENTER"
    AOL_Keyword "mail center"
    Case "PERKS"
    AOL_Keyword "perks"
    Case "WEATHER"
    AOL_Keyword "weather"
    Case Else
    AOL_Keyword LCase(Querry$)
    End Select
End Sub
Public Function AOL_Tool() As Integer
Attribute AOL_Tool.VB_Description = "Returns the handle of the AOL Toolbar"
'By Anubis

AOL% = FindWindow("AOL Frame25", vbNullString)
If AOL_Version() = 4 Then
    Tool% = FindChildByClass(AOL%, "AOL Toolbar")
    AOL_Tool = FindChildByClass(Tool%, "_AOL_TOOLBAR")
   Else
    AOL_Tool = FindChildByClass(AOL%, "AOL Toolbar")
    End If
End Function
Public Sub AOL4_RunToolbar(ByVal Querry As String)
Attribute AOL4_RunToolbar.VB_Description = "Clicks the AOL4 toolbar based on numberical position or a string you pass it as a parameter."
'By Anubis

If AOL_Version() <> 4 Then
    AOL_RunToolbar Querry$
    Exit Sub
    End If
Tool% = AOL_Tool()
Select Case UCase(CStr(Querry$))
    Case "MAIL", "READ", "NEW MAIL", "NEWMAIL", "1"
    Click FindChildByClass(Tool%, "_AOL_ICON")
    Case "WRITE", "COMPOSE", "2"
    Click API_GetNextIcon(Tool%, 2)
    Case "CENTER", "MAIL CENTER", "3"
    Click API_GetNextIcon(Tool%, 3)
    Case "PRINT", "4"
    Click API_GetNextIcon(Tool%, 4)
    Case "MY FILES", "FILES", "5"
    Click API_GetNextIcon(Tool%, 5)
    Case "MY AOL", "MY", "6"
    Click API_GetNextIcon(Tool%, 6)
    Case "FAVORITES", "FAV", "7"
    Click API_GetNextIcon(Tool%, 7)
    Case "INTERNET", "NET", "WWW", "8"
    Click API_GetNextIcon(Tool%, 8)
    Case "CHANNELS", "CHANNEL", "9"
    Click API_GetNextIcon(Tool%, 9)
    Case "PEOPLE", "10"
    Click API_GetNextIcon(Tool%, 10)
    Case "QUOTES", "STOCKS", "11"
    Click API_GetNextIcon(Tool%, 11)
    Case "PERKS", "12"
    Click API_GetNextIcon(Tool%, 12)
    Case "WEATHER", "13"
    Click API_GetNextIcon(Tool%, 13)
    Case "HOT", "NEW"
    AOL_Keyword "hot"
    Case "CHAT", "ROOM"
    AOL_Keyword "lobby"
    Case "FILESEARCH", "SEARCH"
    AOL_Keyword "filesearch"
    Case "NEWS"
    AOL_Keyword "news"
    Case "MARKETPLACE", "MARKET", "CART"
    AOL_Keyword "market place"
    Case "CLOCK", "ONLINE CLOCK"
    AOL_Keyword "online clock"
    Case "PFC", "PERSONAL FILING CABINENT"
    AOL_Keyword "pfc"
    Case "QUESTION", "MEM", "MEMBER", "?"
    AOL_Keyword "member services"
    Case "FIND"
    AOL_Keyword "find"
    Case Else
    AOL_Keyword LCase(Querry$)
    End Select
End Sub
Function API_GetNextIcon(Parent As Integer, Num As Integer) As Integer
Attribute API_GetNextIcon.VB_Description = "Gets the next _AOL_ICON on an object."
'By Anubis

API_GetNextIcon = API_GetNextType(Parent, "_AOL_ICON", Num)
End Function
Function API_GetNextType(Parent As Integer, ByVal ClassToFind As String, Num As Integer) As Integer
Attribute API_GetNextType.VB_Description = "Gets the [Num] [CassToFind] located on the [Parent] window."
'Written by DRAGN, rewrote by Anubis
'AC_GetAOLWin in Core-API.BAS

Init% = FindChildByClass(Parent%, ClassToFind$)
Count% = 1
If Count% = Num% Then
    API_GetNextType% = Init%
    Exit Function
    End If
Waste% = Init%
Do Until Waste% = 0
    DoEvents
    Waste% = GetWindow(Waste%, GW_HWNDNEXT)
    buf$ = String$(255, " ")
    Q% = GetClassName(Waste%, buf$, 254)
    If Left$(LCase(buf$), Len(ClassToFind$)) Like LCase(ClassToFind$) Then Count% = Count% + 1
    If Count% = Num% Then
        API_GetNextType = Waste%
        Exit Function
        End If
    Loop
API_GetNextType = 0
End Function
Function API_GetNextWin(ByVal windowClass As String, ByVal Num As Integer) As Integer
Attribute API_GetNextWin.VB_Description = "Returns the [Num] window with the classname of [windowClass]."
'By Anubis

Init% = FindWindow(windowClass$, vbNullString)
Count% = 1
If Count% = Num% Then
    API_GetNextWin% = Init%
    Exit Function
    End If
Waste% = Init%
Do Until Waste% = 0
    DoEvents
    Waste% = GetWindow(Waste%, GW_HWNDNEXT)
    buf$ = String$(255, " ")
    Q% = GetClassName(Waste%, buf$, 254)
    If Left$(LCase(buf$), Len(windowClass$)) Like LCase(windowClass$) Then Count% = Count% + 1
    If Count% = Num% Then
        API_GetNextWin = Waste%
        Exit Function
        End If
    Loop
API_GetNextWin = 0
End Function
Function API_GetText(ByRef Target As Integer) As String
Attribute API_GetText.VB_Description = "Gets the text of a handle you pass it."
'By Anubis

BufLen% = SendMessageByNum(Target%, WM_GETTEXTLENGTH, 0, 0)
Buffer$ = String(BufLen%, Chr(0))
Q% = SendMessageByString(Target%, WM_GETTEXT, BufLen% + 1, Buffer$)
API_GetText$ = Trim(Left$(Buffer$, Q%))
End Function

Public Function Mail_CountAllMail(Optional ByVal CloseWhenDone As Boolean) As Integer
Attribute Mail_CountAllMail.VB_Description = "Returns the total count of your new mail, old mail and sent mail.  Optionally you can choose to close the mail window[s] when its completed."
'By Anubis
'Thx to OnError for help with mapping Virtual Keys

If IsMissing(CloseWhenDone) Then CloseWhenDone = True

AOL% = AOL_hWnd()
If AOL_Version = 4 Then
    MailNew% = Mail_CountNewMail()
    Timeout 1.3
    MailOld% = Mail_CountOldMail()
    Timeout 1.3
    MailSent% = Mail_CountSentMail()
    Mail_CountAllMail% = MailNew% + MailOld% + MailSent%
    If CloseWhenDone = True Then Win_Close FindChildByTitle(AOL%, AOL_GetSN() & "'s Online MailBox")
    Exit Function
   Else
    For i = 0 To 2
        NewMail% = 0
        MailNum = 0
        MailNum2 = 0
        MailNum3 = 0
        If i = 0 Then
            NewMail% = FindChildByTitle(AOL%, "Outgoing Mail")
            If NewMail% = 0 Then
                RunMenuByString "Check Mail You've &Sent"
                Do Until NewMail% <> 0 Or Mssg% <> 0
                    DoEvents
                    NewMail% = FindChildByTitle(AOL%, "Outgoing Mail")
                    Mssg% = AOL_MsgBox()
                    Timeout 0.001
                    Loop
                End If
           ElseIf i = 1 Then
                NewMail% = FindChildByTitle(AOL%, "Old Mail")
                If NewMail% = 0 Then
                RunMenuByString "Check Mail You've &Read"
                Do Until NewMail% <> 0 Or Mssg% <> 0
                    DoEvents
                    NewMail% = FindChildByTitle(AOL%, "Old Mail")
                    Mssg% = AOL_MsgBox()
                    Timeout 0.001
                    Loop
                End If
           ElseIf i = 2 Then
                NewMail% = FindChildByTitle(AOL%, "New Mail")
                If NewMail% = 0 Then
                RunMenuByString "Read &New Mail"
                Do Until NewMail% <> 0 Or Mssg% <> 0
                    DoEvents
                    NewMail% = FindChildByTitle(AOL%, "New Mail")
                    Mssg% = AOL_MsgBox()
                    Timeout 0.001
                    Loop
                End If
            End If
        If Mssg% <> 0 Then
            Click FindChildByTitle(Mssg%, "OK")
            GoTo Mail_CountAll_Next_i
            End If
        Hand% = FindChildByClass(NewMail%, "_AOL_Tree")
        Do Until MailNum <> 0 And MailNum = MailNum2 And MailNum2 = MailNum3
            DoEvents
            MailNum = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0)
            Timeout (0.1)
            MailNum2 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0)
            Timeout (0.367)
            MailNum3 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0)
            Timeout (0.1)
            Loop
        TotalMail = TotalMail + MailNum3
        If CloseWhenDone = True Then Win_Close NewMail%
Mail_CountAll_Next_i:
        Next i
    Mail_CountAllMail = TotalMail
    End If
End Function

Public Function Mail_CountSentMail() As Integer
Attribute Mail_CountSentMail.VB_Description = "Returns the amount of mail you have sent."
'By Anubis
'Thx to OnError for help with Virtual Keys

AOL% = AOL_hWnd()
If AOL_Version = 4 Then
    Q% = Mail_CountNewMail()
    mailBox% = FindChildByTitle(AOL_hWnd(), AOL_GetSN() & "'s Online Mailbox")
    TabCtrl% = FindChildByClass(mailBox%, "_AOL_TABCONTROL")
    Q% = SendMessage(TabCtrl%, WM_LBUTTONDOWN, 0, 0)
    Q% = SendMessage(TabCtrl%, WM_LBUTTONUP, 0, 0)
    SetForegroundWindow TabCtrl%
    vKey = MapVirtualKey(VK_LEFT, 0)
    keybd_event VK_LEFT, vKey, 0, 0
    keybd_event VK_LEFT, vKey, KEYEVENTF_KEYUP, 0
   Else
    NewMail% = FindChildByTitle(AOL%, "Outgoing Mail")
    If NewMail% = 0 Then
        RunMenuByString "Check Mail You've &Sent"
        Do Until NewMail% <> 0 Or Mssg% <> 0
            DoEvents
            NewMail% = FindChildByTitle(AOL%, "Outgoing Mail")
            Mssg% = AOL_MsgBox()
            Timeout 0.001
            Loop
        End If
    End If
If Mssg% <> 0 Then
    Click FindChildByTitle(Mssg%, "OK")
    Mail_CountSentMail = 0
    Exit Function
    End If
If AOL_Version() = 4 Then
    Timeout 1.3
    TabPage% = API_GetNextType(TabCtrl%, "_AOL_TABPAGE", 3)
    Hand% = FindChildByClass(TabPage%, "_AOL_TREE")
   Else
    Hand% = FindChildByClass(NewMail%, "_AOL_Tree")
    End If
Do Until MailNum <> 0 And MailNum = MailNum2 And MailNum2 = MailNum3
    DoEvents
    MailNum = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Call Timeout(0.7)
    MailNum2 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Call Timeout(0.367)
    MailNum3 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Timeout (0.1)
    If MailNum = 0 Then Timeout 1.3
    Loop
Mail_CountSentMail = MailNum3
End Function

Function Mail_CountNewMail() As Integer
Attribute Mail_CountNewMail.VB_Description = "Returns the amount of new mail you have."
'By Anubis

AOL% = AOL_hWnd()
If AOL_Version = 4 Then
    AOL4_RunToolbar "MAIL"
    Timeout 0.4
    Do Until NewMail% <> 0
        DoEvents
        NewMail% = FindChildByTitle(AOL%, AOL_GetSN() & "'s Online Mailbox")
        Timeout 0.001
        Loop
    Do Until TabPage% <> 0
        DoEvents
        TabControl% = FindChildByClass(NewMail%, "_AOL_TABCONTROL")
        TabPage% = FindChildByClass(TabControl%, "_AOL_TABPAGE")
        Timeout 0.001
        Loop
   Else
    NewMail% = FindChildByTitle(AOL%, "New Mail")
    If NewMail% = 0 Then
        AOL_RunToolbar "MAIL"
        Do Until NewMail% <> 0 Or Mssg% <> 0
            DoEvents
            NewMail% = FindChildByTitle(AOL%, "New Mail")
            Mssg% = AOL_MsgBox()
            Timeout 0.001
            Loop
        End If
    End If
If Mssg% <> 0 Then
    Click FindChildByTitle(Mssg%, "OK")
    Mail_CountNewMail = 0
    Exit Function
    End If
If AOL_Version() = 4 Then
    Hand% = FindChildByClass(TabPage%, "_AOL_TREE")
   Else
    Hand% = FindChildByClass(NewMail%, "_AOL_Tree")
    End If
Do Until MailNum <> 0 And MailNum = MailNum2 And MailNum2 = MailNum3
    DoEvents
    MailNum = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Call Timeout(0.1)
    MailNum2 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Call Timeout(0.367)
    MailNum3 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Timeout (0.1)
    Loop
Mail_CountNewMail = MailNum3
End Function

Public Function Mail_CountOldMail() As Integer
Attribute Mail_CountOldMail.VB_Description = "Returns the amount of old mail you have."
'By Anubis
'Thx to OnError for help with Virtual Keys

AOL% = AOL_hWnd()
If AOL_Version = 4 Then
    Q% = Mail_CountNewMail()
    mailBox% = FindChildByTitle(AOL_hWnd(), AOL_GetSN() & "'s Online Mailbox")
    TabCtrl% = FindChildByClass(mailBox%, "_AOL_TABCONTROL")
    Q% = SendMessage(TabCtrl%, WM_LBUTTONDOWN, 0, 0)
    Q% = SendMessage(TabCtrl%, WM_LBUTTONUP, 0, 0)
    SetForegroundWindow TabCtrl%
    vKey = MapVirtualKey(VK_RIGHT, 0)
    keybd_event VK_RIGHT, vKey, 0, 0
    keybd_event VK_RIGHT, vKey, KEYEVENTF_KEYUP, 0
   Else
    NewMail% = FindChildByTitle(AOL%, "Old Mail")
    If NewMail% = 0 Then
        RunMenuByString "Check Mail You've &Read"
        Do Until NewMail% <> 0 Or Mssg% <> 0
            DoEvents
            NewMail% = FindChildByTitle(AOL%, "Old Mail")
            Mssg% = AOL_MsgBox()
            Timeout 0.001
            Loop
        End If
    End If
If Mssg% <> 0 Then
    Click FindChildByTitle(Mssg%, "OK")
    Mail_CountOldMail = 0
    Exit Function
    End If
If AOL_Version() = 4 Then
    TabPage% = API_GetNextType(TabCtrl%, "_AOL_TABPAGE", 2)
    Hand% = FindChildByClass(TabPage%, "_AOL_TREE")
   Else
    Hand% = FindChildByClass(NewMail%, "_AOL_Tree")
    End If
Do Until MailNum <> 0 And MailNum = MailNum2 And MailNum2 = MailNum3
    DoEvents
    MailNum = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Call Timeout(0.7)
    MailNum2 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Call Timeout(0.367)
    MailNum3 = SendMessageByNum(Hand%, LB_GETCOUNT, 0, 0&)
    Timeout (0.1)
    If MailNum = 0 Then Timeout 1.7
    Loop
Mail_CountOldMail = MailNum3
End Function
Function FindChildByTitle(ByRef Parent As Integer, ByRef child As String) As Integer
Attribute FindChildByTitle.VB_Description = "Returns the handle of a child window or object on a parent window.  Will return the handles of an MDIChild window in an MDIClient environment.  Searches for children based on the text in its caption or the static text it shows."
'from master32.bas, modified by Anubis

childfocus% = GetWindow(Parent, GW_CHILD)

Do Until childfocus% = 0
    DoEvents
    If InStr(UCase(API_GetText(childfocus%)), UCase(child$)) Then
        FindChildByTitle = childfocus%
        Exit Function
        End If
    childfocus% = GetWindow(childfocus%, GW_HWNDNEXT)
    Loop

End Function
Function FindChildByClass(ByRef Parent As Integer, ByRef child As String) As Integer
Attribute FindChildByClass.VB_Description = "Returns the handle of a child window or object on a parent window.  Will return the handles of an MDIChild window in an MDIClient environment.  Searches for children based on classname."
'from master32.bas, modified by Anubis

childfocus% = GetWindow(Parent%, GW_CHILD)

Do Until childfocus% = 0
    Buffer$ = String$(Len(child$), Chr(0))
    classbuffer% = GetClassName(childfocus%, Buffer$, 255)
    If InStr(UCase(Buffer$), UCase(child$)) Then
        FindChildByClass = childfocus%
        Exit Function
        End If
    childfocus% = GetWindow(childfocus%, GW_HWNDNEXT)
    Loop

End Function
Public Sub Room_AddRoom(Lst As ListBox, Optional clearList As Boolean)
Attribute Room_AddRoom.VB_Description = "Places the contents of an AOL room's _AOL_LISTBOX into a Listbox you tell it to.  Only works on 32-bit AOLs."
'From Master32, modified by Anubis

If IsMissing(clearList) Then clearList = True
If clearList = True Then Lst.Clear

On Error Resume Next

Dim AOLProcess As Long
Dim ListItemHold As Long
Dim Person As String
Dim ListPersonHold As Long
Dim ReadBytes As Long
    

Room% = Room_FindRoom()
aolhandle = FindChildByClass(Room%, "_AOL_Listbox")

AOLThread = GetWindowThreadProcessId(aolhandle, AOLProcess)
AOLProcessThread = OpenProcess(PROCESS_VM_READ Or STANDARD_RIGHTS_REQUIRED, False, AOLProcess)

If AOLProcessThread Then
For Index = 0 To SendMessage(aolhandle, LB_GETCOUNT, 0, 0) - 1
Person$ = String$(4, vbNullChar)
ListItemHold = SendMessage(aolhandle, LB_GETITEMDATA, ByVal CLng(Index), ByVal 0&)
ListItemHold = ListItemHold + 24
Call ReadProcessMemory(AOLProcessThread, ListItemHold, Person$, 4, ReadBytes)
                        
Call RtlMoveMemory(ListPersonHold, ByVal Person$, 4)
ListPersonHold = ListPersonHold + 6

Person$ = String$(16, vbNullChar)
Call ReadProcessMemory(AOLProcessThread, ListPersonHold, Person$, Len(Person$), ReadBytes)

Person$ = Left$(Person$, InStr(Person$, vbNullChar) - 1)
Lst.AddItem Person$
Next Index
Call CloseHandle(AOLProcessThread)
End If
End Sub
Public Function AOL_Version() As Integer
Attribute AOL_Version.VB_Description = "Returns the version number of the currently running version of AOL."
'By Anubis

AOL% = FindWindow("AOL Frame25", vbNullString)
Tool% = FindChildByClass(AOL%, "AOL Toolbar")
Tool% = FindChildByClass(Tool%, "_AOL_Toolbar")
If Tool% <> 0 Then AOL_Version = 4: Exit Function
If Menu_MenuExist("&Sign Off") = True Then AOL_Version = 3 Else AOL_Version = 25
End Function
Public Function Mail_ListToString(Lst As ListBox, Optional BCC As Boolean) As String
Attribute Mail_ListToString.VB_Description = "Places all your new mail into a string that is comma delimitated."
'By Anubis

If IsMissing(BCC) Then BCC = True
If Lst.ListCount = 0 Then Mail_ListToString = Null: Exit Function
For i = 0 To Lst.ListCount - 1
    MList = MList & ", " & Lst.List(i)
    Next i
If IsMissing(BCC) Then BCC = True
If BCC = True Then
    Mail_ListToString = CStr("(" & MList & ")")
   Else
    Mail_ListToString = CStr(MList)
    End If
End Function
Public Sub Room_MultiSend(ByVal TXT As String)
Attribute Room_MultiSend.VB_Description = "Capable of splitting up text that is normally to long to send and send it in lines of four with proper TimeOuts between to prevent being logged off."
'By Anubis, just for WiLL

If Len(TXT$) >= 90 Then
    ReDim pseudoPacket(0 To 1) As String * 90
    pseudoPacket(0) = TXT$
    pCount = 1
    GoTo R_MS_Send
    End If
For i = 1 To Len(TXT$)
    If 90 Mod i = 0 Then pCount = pCount + 1
    Next i
ReDim pseudoPacket(0 To pCount) As String * 90
For i = 1 To Len(TXT$)
    If 90 Mod i = 0 Then
        pseudoPacket(sCount) = Mid$(TXT$, i - 89, 90)
        sCount = sCount + 1
        End If
    Next i
R_MS_Send:
For i = 0 To pCount
    If Len(pseudoPacket(i)) > 0 Then
        Send pseudoPacket(i)
        Scroll = Scroll + 1
        If Scroll = 3 Then
            Scroll = 0
            Timeout 1.9
            End If
        End If
    Next i
End Sub

Public Sub Send(ByVal Word As String)
Attribute Send.VB_Description = "Sends the text you tell it to an open chat room."
'By Anubis

Room% = Room_FindRoom()
If Room% = 0 Then Exit Sub
If AOL_Version() = 4 Then
    EditBox% = API_GetNextType(Room%, "RICHCNTL", 2)
   Else
    EditBox% = FindChildByClass(Room%, "_AOL_EDIT")
    End If
DoEvents
SendBttn% = GetWindow(EditBox%, GW_HWNDNEXT)
API_SetText EditBox%, Word$
Click SendBttn%
End Sub
Public Sub Timeout(ByVal Duration As Double)
Attribute Timeout.VB_Description = "Pauses the program for the duration."
'By Anubis

Dim Current As Double
Current = CDbl(Timer)
Do While CDbl(Timer) - Current < Duration
    DoEvents
    Loop
End Sub
Public Sub VB_AddToList(ByVal AddThis As String, Lst As ListBox)
Attribute VB_AddToList.VB_Description = "Adds an item to a listbox, only if no duplicate matches were found."
'By Anubis

newThis$ = LCase(VB_Script(AddThis$, " ", ""))
For i = 0 To Lst.ListCount
    If LCase(VB_Script(AddThis, " ", "")) Like newThis Then Exit Sub
    Next i
Lst.AddItem AddThis$
End Sub
Public Sub VB_KillDupes(Lst As ListBox)
Attribute VB_KillDupes.VB_Description = "Kills all the duplicates in a listbox control."
'By Anubis

For i = 0 To Lst.ListCount
    curItem$ = Lst.List(i)
    For n = 0 To Lst.ListCount
        If n <> i And Lst.List(n) Like curItem$ Then Lst.RemoveItem n
        Next n
    Next i
End Sub
Public Function TrimNull(ByVal Word As String) As String
Attribute TrimNull.VB_Description = "Trims off any extra spaces at the end of a string."
For i = Len(Word$) To 1 Step -1
    If Mid$(Word$, i, 1) <> Chr(0) Then TrimNull$ = Word$: Exit Function
    Word$ = Left$(Word$, i)
    Next i
TrimNull$ = Word$
End Function
Public Function VB_Script(ByVal Strt As String, ByVal ReplaceMe As String, ByVal ReplaceWith As String) As String
Attribute VB_Script.VB_Description = "Scripts out what you tell it to in a string replaces it with what you tell it to."
'By Interrupt, modified by Anubis

Start$ = Strt
Do While InStr(Start$, ReplaceMe$) <> 0
    x% = DoEvents()
    pos% = InStr(Start$, ReplaceMe$)
    Start$ = Left(Start$, pos% - 1) & ReplaceWith$ & Right(Start$, Len(Start$) - pos% - Len(ReplaceMe$) + 1)
    Loop
VB_Script = Start$
End Function
Public Function VB_ScriptSpaces(ByVal Word As String) As String
Attribute VB_ScriptSpaces.VB_Description = "Removes all spaces.  Good for string comparison."
'By Anubis

VB_ScriptSpaces = VB_Script(Word$, " ", "")
End Function
Public Function Room_FindRoom() As Integer
Attribute Room_FindRoom.VB_Description = "Returns the open chat room, if there is one."
'By Anubis

AOL% = FindWindow("AOL Frame25", vbNullString)
MDI% = FindChildByClass(AOL%, "MDIClient")
curFocus% = GetWindow(MDI%, 5)
For i = 0 To 4
    If AOL_Version() = 4 Then
        EditBox% = GetParent(FindChildByClass(curFocus%, "RICHCNTL"))
        CombBox% = GetParent(FindChildByClass(curFocus%, "_AOL_COMBOBOX"))
        ViewBox% = GetParent(FindChildByClass(curFocus%, "RICHCNTL"))
        ListBox% = GetParent(FindChildByClass(curFocus%, "_AOL_LISTBOX"))
        If EditBox% <> 0 And EditBox% = CombBox% And CombBox% = ViewBox% And ViewBox% = ListBox% Then
            Room_FindRoom = EditBox%
            Exit Function
            End If
       Else
        EditBox% = GetParent(FindChildByClass(curFocus%, "_AOL_EDIT"))
        CombBox% = GetParent(FindChildByClass(curFocus%, "_AOL_LISTBOX"))
        ViewBox% = GetParent(FindChildByClass(curFocus%, "_AOL_VIEW"))
        ListBox% = GetParent(FindChildByClass(curFocus%, "_AOL_LISTBOX"))
        End If
    If EditBox% <> 0 And EditBox% = CombBox% And CombBox% = ViewBox% And ViewBox% = ListBox% Then
        Room_FindRoom = EditBox%
        Exit Function
        End If
    curFocus% = GetWindow(curFocus%, GW_HWNDNEXT)
    Timeout 0.001
    Next i
End Function
Public Sub Click(Bttn As Integer)
Attribute Click.VB_Description = "Clicks the handle you pass it, emulating a mouse click."
'By Anubis

DoEvents
Q% = SendMessage(Bttn%, WM_LBUTTONDOWN, 0, 0)
Q% = SendMessage(Bttn%, WM_LBUTTONUP, 0, 0)
End Sub

Public Function AOL_GetSN() As String
Attribute AOL_GetSN.VB_Description = "Returns the screen name of the user."
'From Master32, modified by Anubis

On Error Resume Next
AOL% = FindWindow("AOL Frame25", vbNullString)
MDI% = FindChildByClass(AOL%, "MDIClient")
Welcome% = FindChildByTitle(MDI%, "Welcome,")
WelcomeLength% = GetWindowTextLength(Welcome%)
WelcomeTitle$ = String$(WelcomeLength%, Chr(0))
a% = getwindowtext(Welcome%, WelcomeTitle$, (WelcomeLength% + 1))
AOL_GetSN = Mid$(WelcomeTitle$, 10, (InStr(WelcomeTitle$, "!") - 10))
End Function


Public Sub Win_Align(sourceFrm As Form, FRM As Form, ByVal PositionFlag As Integer)
Attribute Win_Align.VB_Description = "Aligns your form to another form."
'By Anubis

'winUNDERRIGHT = 0
'winUNDERLEFT = 1
'winLEFT = 2
'winRIGHT = 3

Select Case PositionFlag
    Case 0
    FRM.Left = (sourceFrm.Left - sourceForm.Width) + FRM.Width
    FRM.Top = sourceFrm.Top + sourceFrm.Height
    Case 1
    FRM.Left = sourceFrm.Left
    FRM.Top = sourceFrm.Top + sourceFrm.Height
    Case 2
    FRM.Left = sourceFrm.Left - FRM.Width
    FRM.Top = sourceFrm.Top
    Case 3
    FRM.Left = sourceFrm.Left + FRM.Width
    FRM.Top = sourceFrm.Top
    End Select
End Sub

Public Sub Win_Close(Target As Integer)
Attribute Win_Close.VB_Description = "Closes a window."
'By Anubis

DoEvents
Q% = SendMessage(Target%, WM_CLOSE, 0, 0)
End Sub


Public Sub Win_Hide(Target As Integer)
Attribute Win_Hide.VB_Description = "Hides a window."
'By Anubis

DoEvents
Q% = ShowWindow(Target%, SW_HIDE)
End Sub


Public Sub Win_Maximize(Target As Integer)
Attribute Win_Maximize.VB_Description = "Maximizes a window."
'By Anubis

DoEvents
Q% = ShowWindow(Target%, SW_MAXIMIZE)
End Sub

Public Sub Win_Minimize(Target As Integer)
Attribute Win_Minimize.VB_Description = "Minimizes a window."
'By Anubis

DoEvents
Q% = ShowWindow(Target%, SW_MINIMIZE)
End Sub


Sub Win_MoveForm(FRM As Form)
Attribute Win_MoveForm.VB_Description = "Moves a window by clicking and dragging.  Place in any controls _MOUSEDOWN procedure to use it."
'By Anubis

ReleaseCapture
Q& = SendMessage(FRM.hWnd, WM_SYSCOMMAND, MOUSE_MOVE, 0)
End Sub

Public Sub Win_NormalSize(Target As Integer)
Attribute Win_NormalSize.VB_Description = "Returns a window to its normal size."
'By Anubis

DoEvents
Q% = ShowWindow(Target%, SW_NORMAL)
End Sub

Public Sub Win_PositionForm(FRM As Form, ByVal PositionFlag As Integer)
Attribute Win_PositionForm.VB_Description = "Positions a form based on the parameters you pass it."
'By Anubis

'winCENTER = 0
'winLEFTTOP = 1
'winLEFTMIDDLE = 2
'winLEFTBOTTOM = 3
'winRIGHTTOP = 4
'winRIGHTMIDDLE = 5
'winRIGHTBOTTOM = 6
'winCENTERTOP = 7
'winCENTERBOTTOM = 8
Select Case PositionFlag
    Case 0
    With FRM
        .Left = (Screen.Width - .Width) / 2
        .Top = (Screen.Height - .Height) / 2
    End With
    Case 1
    With FRM
        .Left = 0
        .Top = 0
    End With
    Case 2
    With FRM
        .Left = 0
        .Top = (Screen.Height - .Height) / 2
    End With
    Case 3
    With FRM
        .Left = 0
        .Top = (Screen.Height - .Height)
    End With
    Case 4
    With FRM
        .Left = Screen.Width - .Width
        .Top = 0
    End With
    Case 5
    With FRM
        .Left = Screen.Width - .Width
        .Top = (Screen.Height - .Height) / 2
    End With
    Case 6
    With FRM
        .Left = Screen.Width - .Width
        .Top = Screen.Height - .Height
    End With
    Case 7
    With FRM
        .Left = (Screen.Width - .Width) / 2
        .Top = 0
    End With
    Case 8
    With FRM
        .Left = (Screen.Width - .Width) / 2
        .Top = Screen.Height - FRM.Height
    End With
    End Select
        
End Sub

Public Sub Win_Show(Target As Integer)
Attribute Win_Show.VB_Description = "Shows a hidden window."
'By Anubis

DoEvents
Q% = ShowWindow(Target%, SW_SHOW)
End Sub
Public Sub Win_ShowHide(Target As Integer)
Attribute Win_ShowHide.VB_Description = "Show a hidden window or hide a visible window, based on the window's visibility."
'By Anubis

If IsWindowVisible(Target%) = True Then
    DoEvents
    Q% = ShowWindow(Target%, SW_HIDE)
   Else
    DoEvents
    Q% = ShowWindow(Target%, SW_SHOW)
    End If
End Sub
Public Sub Win_ShowHideAOL()
Attribute Win_ShowHideAOL.VB_Description = "Shows/hides AOL."
'By Anubis

AOL% = FindWindow("AOL Frame25", vbNullString)
If IsWindowVisible(AOL%) = True Then
    Q% = ShowWindow(AOL%, SW_HIDE)
   Else
    Q% = ShowWindow(AOL%, SW_SHOW)
    End If
End Sub


Public Sub AOL_Keyword(ByVal Word As String)
Attribute AOL_Keyword.VB_Description = "Runs the keyword for the submitted keyword.  Will run a silent keyword if used for AOL 4.0."
'by Anubis

AOL% = AOL_hWnd()
If AOL_Version() = 4 Then
    AOL4_SilentKeyword (Word$)
    Exit Sub
   Else
    RunMenuByString ("Keyword...")
    End If
Do Until KeyEdit% <> 0
    DoEvents
    KW% = FindChildByTitle(AOL%, "Keyword")
    KeyEdit% = FindChildByClass(KW%, "_AOL_EDIT")
    Timeout 0.001
    Loop
API_SetText KeyEdit%, Word$
Click FindChildByClass(KW%, "_AOL_ICON")
End Sub
Public Sub RunMenuByString(ByVal StringSearch As String)
Attribute RunMenuByString.VB_Description = "Runs a menu based on the strings you tell it."
'From Master32, modified by Anubis

AOL% = FindWindow("AOL Frame25", vbNullString)
ToSearch% = getmenu(AOL%)
MenuCount% = GetMenuItemCount(ToSearch%)

For findstring = 0 To MenuCount% - 1
    ToSearchSub% = GetSubMenu(ToSearch%, findstring)
    MenuItemCount% = GetMenuItemCount(ToSearchSub%)
    For GetString = 0 To MenuItemCount% - 1
        SubCount% = GetMenuItemID(ToSearchSub%, GetString)
        MenuString$ = String$(100, Chr(0))
        GetStringMenu% = GetMenuString(ToSearchSub%, SubCount%, MenuString$, 100, 1)
        If InStr(UCase(MenuString$), UCase(StringSearch)) Then
            MenuItem% = SubCount%
            GoTo MatchString
            End If
        Next GetString
    Next findstring
MatchString:
DoEvents
Q% = SendMessage(AOL%, WM_COMMAND, MenuItem%, 0)
End Sub
Public Sub API_SetText(Target As Integer, ByVal Word As String)
Attribute API_SetText.VB_Description = "Replaces the text on the handle you pass it with the string you tell it to."
'By Anubis

Q% = SendMessageByString(Target%, WM_SETTEXT, 0, CStr(Word$))
End Sub
Public Function AOL_hWnd() As Integer
Attribute AOL_hWnd.VB_Description = "Returns the handle of America Online.  Similiar to using: AOL% = FindWindow(""AOL Frame25"", vbNullString). "
'By Anubis

AOL% = FindWindow("AOL Frame25", vbNullString)
AOL_hWnd = FindChildByClass(AOL%, "MDIClient")
End Function

Public Sub Win_ShowHideTool()
Attribute Win_ShowHideTool.VB_Description = "Shows/hides AOL's toolbar."
'By Anubis

Tool% = AOL_Tool()
If IsWindowVisible(Tool%) = True Then
    Win_Hide (Tool%)
   Else
    Win_Show (Tool%)
    End If
Win_Minimize AOL_hWnd()
Win_Maximize AOL_hWnd()
End Sub
Public Sub Win_StayOnTop(FRM As Form)
Attribute Win_StayOnTop.VB_Description = "Keeps a window on top of all other windows."
'By Anubis

Q% = SetWindowPos(FRM.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub
Function AOL_GetHostName(Optional AOLDir As String) As String
'By Anubis

If IsMissing(AOLDir) Then AOLDir = AOL_AOLDir()
Host$ = String$(40, " ")
If AOL_Version() = 3 Or AOL_Version() = 4 Then
    chat$ = "aolchat.aol"
    PNum = 4761
    V% = 9
   Else
    chat$ = "chat.aol"
    PNum = 6887
    V% = 6
    End If
If FileExist("c:\" & AOLDir & "\tool\" & chat$) = False Then
    AOL_GetHostName$ = "&&null"
    Exit Function
    End If
Open "C:\" + AOLDir$ + "\tool\" & chat$ For Binary As #1
Seek #1, PNum
Get #1, PNum, Host$
Close #1
Host$ = Left$(Host$, InStr(Host$, "%s") - V%)
AOL_GetHostName$ = Trim(Host$)
End Function
Public Sub Win_Oval(FRM As Form)
Attribute Win_Oval.VB_Description = "Creates an Oval window."
'By Anubis

xWidth = FRM.Width / Screen.TwipsPerPixelX
yHeight = FRM.Height / Screen.TwipsPerPixelY
elhWnd = CreateEllipticRgn(0, 0, xWidth, yHeight)
SetWindowRgn FRM.hWnd, elhWnd, True
Q% = DeleteObject(elhWnd)
End Sub
Public Sub Win_ExitWindows(Optional exitMode As Integer, Optional mBoxPrompt As Boolean)
Attribute Win_ExitWindows.VB_Description = "Exit windows."
If IsMissing(exitMode%) Then exitMode = 0
If IsMissing(mBoxPrompt) Then mBoxPrompt = False
If mBoxPrompt = True Then
    Select Case exitMode%
        Case 1
            exitType$ = "reboot your computer"
        Case 2
            exitType$ = "restart Microsoft Windows"
        Case Else
            exitType$ = "exit to MS DOS"
        End Select
    MBox% = MsgBox("Are you sure you wish to " & exitType$ & "?", vbYesNo + vbQuestion, App.Title)
    If MBox% = 7 Then Exit Sub
    End If
Select Case exitMode%
    Case 1
        Q% = ExitWindows(67, 0) 'reboot the computer
    Case 2
        Q% = ExitWindows(66, 0) 'restart Windows
    Case Else
        Q% = ExitWindows(0, 0) 'exit Windows
    End Select
End Sub



